/*
 * assert.c
 *
 *  Created on: 2016-11-10
 *      Author: m
 */

#include "debug.h"
#include "string.h"
#include "sub.h"

void assert_failed(char* exp, char* fn, int line) {
    tc_printf(TA_FOREGROUND_RED | TA_FOREGROUND_INTESITY, "[%s:%d] assert %s FAILED!\n", fn, line, exp);
}

void assert_eq_failed_i(char* fn, int line, int real, int expect) {
    tc_printf(TA_FOREGROUND_RED | TA_FOREGROUND_INTESITY, "[%s:%d] assert_eq FAILED expect=0x%x but real=0x%x!\n", fn, line, expect, real);
}

void assert_failed_a(char* exp, char* fn, int line, int ng_action) {
    tc_printf(TA_FOREGROUND_RED | TA_FOREGROUND_INTESITY, "[%s:%d] assert %s FAILED!\n", fn, line, exp);
    if(NG_ACT_HALT == ng_action) {
        tc_printf(TA_FOREGROUND_RED, "system hlt!\n");
        di();
        __asm__ __volatile__("hlt");
    }
}
